﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMS.Core.DataEntity;
using SMS.Common.DataAccess;
using SMS.Common.Search;

namespace SMS.Core.DataAccess
{
    public class SMSAccess : DataAccessBase<SMSDataContext>
    {
        #region SendMessage

        /// <summary>
        /// 获取发送短信
        /// </summary>
        public List<SendMessage> GetWaittingMessage(int count)
        {
            using (var dc = CurrentContext)
            {
                return dc.SendMessage.Where(d => d.Status == (int)Status.Waitting && (d.ExpireTime == null || d.ExpireTime >= DateTime.Now)).OrderBy(d => d.AddTime).OrderByDescending(d => d.Priority).Take(count).ToList();
            }
        }

        /// <summary>
        /// 获取发送短信
        /// </summary>
        public List<SendMessage> GetWaittingMessage()
        {
            using (var dc = CurrentContext)
            {
                return dc.SendMessage.Where(d => d.Status == (int)Status.Waitting && (d.ExpireTime == null || d.ExpireTime >= DateTime.Now)).OrderBy(d => d.AddTime).OrderByDescending(d => d.Priority).ToList();
            }
        }

        #endregion

        #region ReceiveMessage
        

        #endregion

        #region SMSMessage


        #endregion
    }
}
